<!DOCTYPE html>
<html xmlns:th="http://www.springframework.org/schema/jdbc">
<head>
    <meta charset="utf-8">
    <title>用户--添加</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/components/layuiadmin/layui/src/css/layui.css">
    <link rel="stylesheet" href="/manage/css/base-search.css" media="all">


    <script src="/manage/js/app.js"></script>
</head>
<style>
    .layui-input-inline {
        width: 80% !important;
    }
</style>
<body>


<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">


    <div class="layui-form-item">
        <label class="layui-form-label layui-required">连接地址</label>
        <div class="layui-input-inline">
            <input type="text" id="dbUrl" name="dbUrl" value="127.0.0.1" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label layui-required">账号</label>
        <div class="layui-input-inline">
            <input type="text" id="dbUsername" name="dbUsername" value="root" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label layui-required">密码</label>
        <div class="layui-input-inline">
            <input type="password" id="dbPassword" name="dbPassword" value="" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <!-- 连接测试 -->
    <div class="layui-form-item">
        <div class="layui-input-inline">
            <button style="margin-left: 110px" type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="datasourceTest()">连接测试</button>
        </div>
    </div>
    <!-- 连接测试 -->
    <div class="layui-form-item">
        <label class="layui-form-label layui-required">命名</label>
        <div class="layui-input-inline">
            <input type="text" id="dbTitle" name="dbTitle" lay-verify="required" placeholder="请输入自定义名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label layui-required">库名</label>
        <div class="layui-input-inline">
            <input type="text" id="dbName" name="dbName" lay-verify="required" placeholder="数据库库名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">表前缀</label>
        <div class="layui-input-inline">
            <input type="text" id="dbPrefix" name="dbPrefix" placeholder="表前缀, 用与过滤表前缀数据" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">字段前缀</label>
        <div class="layui-input-inline">
            <input type="text" id="dbFieldPrefix" name="dbFieldPrefix" placeholder="字段前缀, 用与过滤字段前缀数据" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">通用字段</label>
        <div class="layui-input-inline">
            <input type="text" id="dbGeneralField" name="dbGeneralField" placeholder="通用字段, 多个逗号分隔" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">包根路径</label>
        <div class="layui-input-inline">
            <input type="text" id="packPath" name="packPath" placeholder="该配置暂无效" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">父模块名</label>
        <div class="layui-input-inline">
            <input type="text" id="modules" name="modules" placeholder="该配置暂无效" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">子模块名</label>
        <div class="layui-input-inline">
            <input type="text" id="modulesName" name="modulesName" placeholder="该配置暂无效" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">
    </div>
</div>

<script>
    layui.use(['form'], function () {
        //监听提交
        layui.form.on('submit(layuiadmin-app-form-submit)', function (data) {
            let result = Ajax.post(parent.datasourceUrl, data.field);
            let index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
            parent.layer.msg(result.msg);
            //重载表格
            parent.xijiaRenderTable();
            // 重载后-刷新分页数据
            parent.xijiaLayPage();
        });

        layui.form.on('submit(layuiadmin-app-form-test)', function (data) {

        });
    });


    // 数据源连接测试
    function datasourceTest() {
        let data = {
            dbUrl: $("#dbUrl").val(),
            dbUsername: $("#dbUsername").val(),
            dbPassword: $("#dbPassword").val()
        };
        let result = Ajax.post(parent.datasourceDataSourceTest, data);
        let index = parent.layer.getFrameIndex(window.name);
        parent.layer.msg("连接成功");
    }
</script>
</body>
</html>
